--- @diagnostic disable: duplicate-doc-field, missing-return, duplicate-doc-alias
--- @meta

--- @class Csharp.Stream 文件流
--- @class Csharp.Font
--- @class Csharp.RectangleF

--- @class Csharp.Task 异步任务
--- @field Wait fun(self:self)

--- @class Csharp.Color
--- @field [1] integer R
--- @field [2] integer G
--- @field [3] integer B
Color = {}

--- @enum Csharp.StringAlignment
StringAlignment = {
    Near = 0,
    Center = 1,
    Far = 2
}

---创建Font
---@param fontName "微软雅黑"|string
---@param fontSize integer
---@return Csharp.Font
function Font(fontName, fontSize) end

---创建RectangleF
---@param x number
---@param y number
---@param w number
---@param h number
---@return Csharp.RectangleF
function RectangleF(x, y, w, h) end

--- @class Csharp.Image
--- @field Open fun(path:string):Csharp.Image 从图片文件加载图片
--- @field Create fun(w:integer,h:integer):Csharp.Image 创建空白图片
--- @field W integer 宽度
--- @field H integer 高度
--- @field WriteBlockColor fun(self:self,R:integer,G:integer,B:integer,A?:integer) --填充背景色
--- @field WriteColor fun(self:self,R:integer,G:integer,B:integer,A?:integer) --输出一层颜色
--- @field AddBlend fun(self:self,inputPath:string,x:integer|nil,y:integer|nil,w:integer|nil,h:integer|nil) 合成 path 图片
--- @field AddBlend fun(self:self,image:Csharp.Image,x:integer|nil,y:integer|nil,w:integer|nil,h:integer|nil) 合成 path 图片
--- @field SetSize fun(self:self,w:integer,h:integer) 设置图片大小
--- @field Close fun(self:self) 关闭图片，一定要关闭图片
Image = {}

--- 输出文本
--- @param text string 文本
--- @param font Csharp.Font 字体
--- @param colors table<integer,Csharp.Color> 颜色列表
--- @param rect? Csharp.RectangleF 区域
--- @param align? Csharp.StringAlignment 对齐方式
function Image:WriteText(text, font, colors, rect, align) end

--- 保存图片
--- #### 支持的类型
--- * jpg
--- * png
--- * bmp
--- * tga
--- * blp
--- @param filePath string 图片路径
function Image:Save(filePath) end

--- @class DirectoryInfo
--- @field Name string
--- @field Exists string
--- @field Parent  DirectoryInfo?
--- @field Root DirectoryInfo
--- @field Create fun(self:self)
--- @field CreateSubdirectory fun(self:self,path:string):DirectoryInfo
--- @field Delete fun(self:self)


--- @class FileInfo
--- @field IsReadOnly boolean 是否只读
--- @field Exists boolean 是否存在
--- @field DirectoryName string?
--- @field Directory DirectoryInfo?
--- @field Length integer
--- @field Name string 文件名
--- @field FullName string 绝对路径
--- @field CopyTo fun(self:self,destFileName:string):FileInfo
--- @field Delete fun(self:self)
--- @field MoveTo fun(self:self,destFileName:string)
--- @field ToString fun(self:self):string 获取文件路径

---创建FileInfo
---@param path string
---@return FileInfo
function FileInfo(path) end

---@class Csharp.Encoding
---@field UTF8 Csharp.Encoding
---@field ASCII Csharp.Encoding
---@field Unicode Csharp.Encoding
Encoding = {}

--- @class Csharp.IO
--- @field Read fun(filePath:string):string 读取指定路径的文件
--- @field ReadBinary fun(filePath:string):byte 读取指定路径的文件
--- @field Write fun(filePath:string,content:string|Csharp.Stream|byte) 写入指定路径的文件
--- @field IsDirectoryExists fun(Directory:string):boolean 判断文件夹是否存在
--- @field IsFileExists fun(filePath:string):boolean 判断文件是否存在
--- @field Exists fun(filePathOrDirectory:string):boolean 判断文件或文件夹是否存在
--- @field Delete fun(filePath:string):boolean 删除文件
--- @field IsFileLocked fun(filePath:string):boolean 检查文件是否被占用
--- @field CreateDirectory fun(path:string) 创建文件夹
--- @field GetExeDirPath fun():string 获取当前CLua.exe所在目录
--- @field GetWorkingDirectory fun():string 获取当前工作目录
--- @field GetYDWEPath fun():string 获取关联的YDWE目录
--- @field GetWar3ExePath fun():string 获取关联的War3.exe路径
--- @field GetWar3InstallPath fun():string 获取关联的War3目录
IO = {}

---遍历文件夹
---@param folderPath string 文件夹路径
---@param callback fun(filePath: FileInfo) 文件回调
---@param format? string "*.*"|"*.blp" 这种格式，默认是*.*
function IO.ForDirectoryInfo(folderPath, callback, format) end

--- @class Csharp.HttpGet
--- @overload fun(url:string):Csharp.HttpGet 发起Get请求
--- @field SendLua fun(self:self,callback:fun(result:string)):Csharp.Task 发起Get请求
--- @field Wait fun(self:self) 等待请求完成
--- @field DownloadStreamAsync fun(self:self,callback:fun(stream:Csharp.Stream)):Csharp.Task 下载文件
HttpGet = {}

--- @class Csharp.HttpPost
--- @overload fun(url:string,body:table?,headers:table?):Csharp.HttpPost
--- @field SendLua fun(self:self,callback:fun(result:string)):Csharp.Task 发起Get请求
--- @field Wait fun(self:self) 等待请求完成
HttpPost = {}


--- @class Csharp.Json
--- @field decode fun(json:string):table 解析json字符串为table
--- @field encode fun(data:table):string 转换table
json = {}

--- @enum(partial) ICellType
local CellType =
{
    Unknown = -1,
    Numeric = 0,
    String = 1,
    Formula = 2,
    Blank = 3,
    Boolean = 4,
    Error = 5,
}

--- @class Csharp.Cell
--- @field OwnerRow Csharp.Row
--- @field NumericCellValue number 获取值
--- @field BooleanCellValue boolean 获取值
--- @field StringCellValue string 获取正常字符串值（不带颜色）
--- @field StringWar3 string 获取魔兽字符串值（带|cFFFFFFFF颜色代码）
--- @field RowIndex integer
--- @field ColumnIndex integer
--- @field TypeCode ICellType
Cell = {}

--- @class Csharp.Row
--- @field [integer] Csharp.Cell
--- @field OwnerSheet Csharp.Sheet
--- @field RowNum integer 当前所在行数
--- @field CellNum integer 格子数量
--- @field LastCellNum integer 最后一个格子的位置
--- @field GetCell fun(self:self,x:integer):Csharp.Cell 获取或创建指定单元格
Row = {}

--- @class Csharp.Sheet
--- @field OwnerXlsx Csharp.Xlsx
--- @field FirstRowNum integer 第一行行数
--- @field LastRowNum integer 最后一行行数
--- @field SheetName string 工作簿名字
--- @field GetCell fun(self:self,row:integer,col:integer):Csharp.Cell 获取指定单元格
--- @field GetRow fun(self:self,row:integer):Csharp.Row 获取指定行
Sheet = {}


--- @class Csharp.Xlsx
--- @field HasSheet fun(self:self,name:string):boolean 判断工作簿是否存在
--- @field GetSheet fun(self:self,name:string):Csharp.Sheet? 获取工作簿
--- @field CreateSheet fun(self:self,name:string):Csharp.Sheet? 创建工作簿
--- @field Save fun(self:self,filename:string):boolean 保存工作表到指定路径
--- @field RealWPSId fun(excelId:string,callback:fun(xlsx:Csharp.Xlsx)):Csharp.Task
--- @field Dispose fun() 关闭表格
--- @overload fun(stream:string):Csharp.Xlsx
--- @overload fun():Csharp.Xlsx
Xlsx = {}


--- @class Csharp.ModelParse
ModelParse = {}

---@overload fun(file:War3Map.MpqFile):Csharp.Model?
---@overload fun(path:string):Csharp.Model?
function ModelParse.Open(any) end

---@overload fun(buffer:byte):Csharp.Model? 二进制数据读取模型
function ModelParse.Read(any) end

--- @class Csharp.LaunchRunOption
--- @field IsWait? boolean 是否等待（默认false）
--- @field HideWindow? boolean 是否隐藏窗口（默认false）
--- @overload  fun():Csharp.LaunchRunOption
LaunchRunOption = {}

--- @class Csharp.Launch
--- @field AddArg fun(self:self,v:string) 添加参数
--- @field RemoveArg fun(self:self,v:string) 删除参数
--- @field Set fun(self:self,k:string,v:string) 设置参数
--- @field InjectDll fun(self:self,dllPath:string) 注入32位DLL
--- @field Run fun(self:self,Option?:Csharp.LaunchRunOption) 启动程序

---@class Csharp.TasksGroup
local TasksGroup = {}

---添加线程
---@param script string
---@param config? any 传入的参数
function TasksGroup:AddAction(script, config)

end

---等待所有线程
---@return Csharp.Task
---@nodiscard
function TasksGroup:WaitAll()

end

---创建运行器
---@param exe string
---@return Csharp.Launch
function Launch(exe) end

---解析Ini文件数据
---@param buf string
---@return table
function Lni(buf) end

--—创建一个线程任务组
---@return Csharp.TasksGroup
function Tasks() end

---取出资源文件
---@param filename string
---@return string
function CLuaResource(filename) end
